<?php 
class Sites extends E_Entity 
{
	public   $table =array(
					"id" =>"id",
					"version" =>"version",
					"userid" =>"userid",
					"title" =>"title",  
					"logo" =>"logo",  
					"descript" =>"descript",
					"style" =>"style",
					"sign" =>"sign",
					"status" =>"status",
					"ctime" =>"ctime",
					"mtime" =>"mtime"
					);
	public function getTableName()
	{
		return "micro_site";
	}
	public function getJoinMap()
	{
		$map = array("mapGroup" =>array("Entity"=>"Groups","Method"=>"getById", "param"=>"groupid"),
					 "mapUser" =>array("Entity"=>"Users","Method"=>"getById", "param"=>"userid")
			);
		return $map;
	}
	public static function insertEntity($row)
	{	
		$entity = new self();
	 	return $entity->createEntityForRow($row);
	}
	public static function getById($id)
	{
		$entity = new self();
		$sql =  "select * from {$entity->getTableName()} where  {$entity->table['id']} = :id";
		return $entity->getEntityByIndexKey($sql, $id, array("id"=>$id));
	}
	public static function getByUserid($userid)
	{
		$entity = new self();
		$sql =  "select * from {$entity->getTableName()} where  {$entity->table['userid']} = :userid";
		return $entity->getEntityByIndexKey($sql, $id, array("userid"=>$userid));
	}
	public static function getList($where = " 1=1 " ,$limit = '', $order = 'order by ctime desc')
	{
		$entity = new self();
		$sql =  "select * from {$entity->getTableName()} where $where  and  status=1 $order $limit ";
		return $entity->birthEntity($sql);
	}
	public function getSmalllogo()
	{
		$logo = $this->logo;
		if(!empty($logo))
		{
			$first_array = explode(".", $logo);
			return $first_array[0]."_180X240_48X48.".$first_array[1];
			
		}	
		else
		{
			return '';
		}
	}
	public function getLargelogo()
	{
		$logo = $this->logo;
		if(!empty($logo))
		{
			$first_array = explode(".", $logo);
			return $first_array[0]."_180X240.".$first_array[1];
			
		}	
		else
		{
			return '';
		}
	}
}
?>